public class ModuleStandardController {
/**********************************************************/ 
    Module__c modulo;
    public transient blob file{get; set;}
    Attachment docAtt {get; set;}
    
/****************************METODOS GET*******************************************/
    public Module__c getModulo(){
        System.debug('Inicializando Modulo modulo');
        if(modulo==null)modulo = new Module__c();
        return modulo;
    }
    public Attachment getDocAtt(){
        System.debug('Inicializando Attachment docAtt');
        if(docAtt==null)docAtt = new Attachment();
        return docAtt;
    }
    
/****************************METODOS DocumentUpload*******************************************/   
    public void uploadFile(){
        System.debug('Entering uploadFile');
        try{
            
            System.debug('Module__c FileID = '+modulo.FileID__c);
            docAtt = new Attachment();
            docAtt.Body = file;
            docAtt.ParentId=modulo.Id;
            //System.debug('Entrando a insertar el attachment de file');
            docAtt.Name = modulo.Name+'-'+modulo.Id+'.'+modulo.Document_Format__c;
            //docAtt.Name = docAtt.ParentId = modulo.Id;
            //docAtt.Name = file.toString();
            
            insert docAtt;
            modulo.FileID__c = docAtt.Id;
            update modulo;
            
//            
        }catch(Exception ex){
            System.debug('An error has ocurred : ModuleStandardController: uploadFile: '+ex.getMessage());
        }
        
    }
    public Pagereference save(){
        try{
            insert modulo;
            uploadFile();
            return (new ApexPages.Standardcontroller(modulo)).view();
        }catch(Exception ex){
            System.debug('An error has ocurred : AccountStandardController: finish: '+ex.getMessage());
        }
        return null;
    }     
}